package besta.moon.sql.expression.function.numeric;

import besta.moon.sql.expression.function.FunctionReturnInt;
import besta.moon.sql.parser.SQLTokenizer;

public final class FunctionMod extends FunctionReturnInt {

    @Override
    public final int getFunction() {
        return SQLTokenizer.MOD;
    }

    @Override
    public boolean isNull() throws Exception {
        return param1.isNull() || param2.isNull();
    }

    @Override
    public final int getInt() throws Exception {
        if (isNull()) {
            return 0;
        }
        return param1.getInt() % param2.getInt();
    }
}
